using System;
using ProjectEuler.Core.Helpers;

namespace ProjectEuler.Core
{
    public class Problem7 : IProjectEulerProblem
    {
        public static long FindTheNthPrime(int n)
        {
            int i = 2;
            int primenumbersfound = 0;
            while(i < int.MaxValue)
            {
                if(MathHelper.IsPrime(i))
                {
                    primenumbersfound++;
                    if(primenumbersfound == n)
                    {
                        return i;
                    }
                }
                i++;
            }
            throw new OverflowException("You want a prime that's too big, you mad man!");
        }

        public int Number
        {
            get { return 7; }
        }

        public string Description
        {
            get { return "Find the 10001st prime number"; }
        }

        public string Answer
        {
            get { return FindTheNthPrime(10001).ToString(); }
        }
    }
}